package cn.javase.io_model.bio._03_伪异步IO编程;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class SocketServerPool {

    private ExecutorService executorService; // 线程池成员变量

    public SocketServerPool(int maxTreadNum, int queueSize) {
        executorService = new ThreadPoolExecutor(3, maxTreadNum,
            120, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize));
    }

    // 提供一个方法提交任务给线程池的任务队列来暂存，等着线程池来处理
    public void execute(Runnable runnable) {
        executorService.execute(runnable);
    }

}
